package com.wjjun.base.ui.viewmodel

import androidx.databinding.ObservableField
import com.wjjun.base.ui.state.ToolBarState

/**
 *
 * 基础Activity的viewModel
 * author : wangjunjun
 * date   : 2022/5/31
 * desc   :
 */
open class BaseActivityViewModel() : BaseWindowViewModel() {

    /**
     * 是否显示标题栏
     */
    val showToolBar = ObservableField<Boolean>(true)

    val showBackIcon = ObservableField<Boolean>(true)

    /**
     * 布局文件id
     */
    val layoutId = ObservableField(0)

    /**
     * 标题栏数据
     */
    val titleBarData = ToolBarState()

    fun setTitle(title: String) {
        titleBarData.title.set(title)
    }

    fun setSubTitle(subTitle: String) {
        titleBarData.subTitle.set(subTitle)
    }

    fun setLeftIcon(iconRes: Int) {
        titleBarData.leftIcon.set(iconRes)
    }

    fun setRightText(name: String) {
        titleBarData.rightText.set(name)
    }
    fun setRightFirstIcon(iconRes: Int) {
        titleBarData.rightFirstBtnResId.set(iconRes)
    }
    fun setRightSecondIcon(iconRes: Int) {
        titleBarData.rightSecondBtnResId.set(iconRes)
    }

    override fun getLayoutId(): Int {
        return layoutId.get() ?: 0
    }
}